﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Text;

namespace MyVocationSpace.AJAX
{
    public partial class GetAllIndustryAndVocation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BAL.conn.connectionString = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
            string strSearch = "";
            if (Request.QueryString["strSearch"] != null)
            {
                strSearch = Request.QueryString["strSearch"];
            }
            if (Request.QueryString["flag"] != null)
            {
                int flag = Convert.ToInt32(Request.QueryString["flag"]);
                StringBuilder strResponse=new StringBuilder();           
               
                DataSet ds;
                if (flag == 1)
                {

                    ds = BAL.Industry.GetAllIndustry(strSearch);

                    strResponse.Append("<ul   class=\"PopupList\">");
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow dr in ds.Tables[0].Rows)
                            {
                                strResponse.Append("<li><a href=\"SearchMemberList.aspx?Industry=" + dr["IndustryName"].ToString() + "&Vocation=\"  target=\"_blank\">" + dr["IndustryName"].ToString() + "</a></li>");
                                //strResponse.Append("<li><a href=\"SearchMemberList.aspx?Industry=" + dr["IndustryName"].ToString() + "</a></li>");
                            }
                        }
                        else
                        {
                            strResponse.Append("<li>No Data Found........</li>");
                        }
                    }
                   
                    strResponse.Append("</ul>");

                }
                else
                {
                    ds = BAL.Vocation.GetAllVocation(strSearch);
                    strResponse.Append("<ul class=\"PopupList\">");
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow dr in ds.Tables[0].Rows)
                            {
                               // strResponse.Append("<li><a href=\"SearchMemberList.aspx?Vocation=" + dr["VocationName"].ToString() + "</a></li>");
                                strResponse.Append("<li><a href=\"SearchMemberList.aspx?Vocation=" + dr["VocationName"].ToString() + "&Industry=\" target=\"_blank\">" + dr["VocationName"].ToString() + "</a></li>");
                                 
                            }
                        }
                    }
                    strResponse.Append("</ul>");
                }
                Response.Write(strResponse.ToString());
            }
            Response.End();
        }
    }
}